package com.bytz.modules.cms.order.schedule;

import com.bytz.modules.cms.order.service.IOrderBillService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.time.LocalDateTime;

@Component
@Slf4j
public class SendBillEmailJon implements Job {

    @Autowired
    protected IOrderBillService orderBillService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            // 凌晨给财务发送前一天的账单
            orderBillService.sendDailyBill(LocalDateTime.now().minusDays(1));
        } catch (IOException e) {
            log.error("账单邮件发送失败", e);
        }
    }
}
